package net.sunofbeach.blog.controller.portal;

import net.sunofbeach.blog.pojo.NewComment;
import net.sunofbeach.blog.response.ResponseResult;
import net.sunofbeach.blog.services.INewCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/portal/newComment")
public class NewCommentPortalApi {

    @Autowired
    private INewCommentService newCommentService;


    @PostMapping
    public ResponseResult postNewComment(@RequestBody NewComment newComment) {
        return newCommentService.postNewComment(newComment);
    }

    @GetMapping("/list/{page}/{size}")
    public ResponseResult listNewComments(@PathVariable("page") int page,
                                          @PathVariable("size") int size) {
        return newCommentService.listNewComments(page, size);
    }

    @GetMapping("/count")
    public ResponseResult getNewCommentCount() {
        return newCommentService.getNewCommentCount();
    }

    @GetMapping("/list/{articleId}/{page}/{size}")
    public ResponseResult listNewComments(@PathVariable("articleId") String articleId,
                                          @PathVariable("page") int page,
                                          @PathVariable("size") int size) {
        return newCommentService.listNewCommentByArticleId(articleId,page,size);
    }
}
